import java.util.*;

public class Main {


    public static List<String> topKFrequent(String[] words, int k) {
        HashMap<String,Integer> map = new HashMap<>();
        for (String s : words) {
            if(map.get(s) == null) {
                map.put(s,1);
            }else {
                Integer val = map.get(s);
                map.put(s,val+1);
            }
        }
        //走到这里  单词出现几次 都统计好了
        PriorityQueue<Map.Entry<String,Integer>> minHeap
                = new PriorityQueue<>(k,new Comparator<Map.Entry<String, Integer>>() {
            @Override
            public int compare(Map.Entry<String, Integer> o1,
                               Map.Entry<String, Integer> o2) {
                if(o1.getValue().compareTo(o2.getValue()) == 0) {
                    return o2.getKey().compareTo(o1.getKey());
                }
                return o1.getValue()-o2.getValue();
            }
        });
       Set<Map.Entry<String,Integer>> entrySet = map.entrySet();
        for (Map.Entry<String, Integer> entry : entrySet) {
            if(minHeap.size() < k) {
                minHeap.offer(entry);
            }else {
                Map.Entry<String,Integer> top = minHeap.peek();
                if(top.getValue().compareTo(entry.getValue()) == 0) {
                    if(top.getKey().compareTo(entry.getKey()) > 0 ) {
                        minHeap.poll();
                        minHeap.offer(entry);
                    }
                }else {
                    if(top.getValue() < entry.getValue()) {
                        minHeap.poll();
                        minHeap.offer(entry);
                    }
                }
            }
        }
       // System.out.println(minHeap);

        List<String> ret = new ArrayList<>();
        for (int i = 0; i < k; i++) {
            String str = minHeap.poll().getKey();
            ret.add(str);
        }//2 3 4
        Collections.reverse(ret);
        return ret;
    }


    public static void main(String[] args) {
        //String[] worlds = {"the", "day", "is", "sunny", "the", "the", "the", "sunny", "is", "is"};
        String[] worlds = {"i", "love", "leetcode", "i", "love", "coding"};
        topKFrequent(worlds,3);
    }


    public static void func(String strExe,String strAct) {
        HashSet<Character> set1 = new HashSet<>();
        for (char ch : strAct.toUpperCase().toCharArray()) {
            set1.add(ch);
        }

        HashSet<Character> setBroken = new HashSet<>();

        //set好的键
        for (char ch :strExe.toUpperCase().toCharArray()) {
            if(!set1.contains(ch) && !setBroken.contains(ch)) {
                System.out.println(ch);
                setBroken.add(ch);
            }
        }
    }

    public static void main1(String[] args) {
        Scanner scanner = new Scanner(System.in);
        while(scanner.hasNextLine()) {
            String strExe = scanner.nextLine();
            String strAct = scanner.nextLine();
            func(strExe,strAct);
        }
    }

}